FROM python:3.12-alpine

MAINTAINER Logan <admin@attacker.club>
WORKDIR /opt/app

# 复制依赖文件
COPY requirements.txt /opt/app/

# 国内加速源
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories 

# 安装依赖
RUN apk --no-cache add gcc libc-dev jpeg-dev zlib-dev libffi-dev \
    mariadb-dev mysql-client curl busybox-extras \
    tzdata bash git openssh-client
RUN pip --no-cache-dir install -i https://mirrors.aliyun.com/pypi/simple -r requirements.txt

# 复制项目文件
COPY . /opt/app/

# 清理构建依赖
RUN apk del gcc libc-dev
RUN rm -rf /tmp/* /root/.cache/pip /var/cache/apk/*

# 赋予脚本执行权限
RUN chmod +x /opt/app/run.sh

# 暴露端口
EXPOSE 8000

# 启动命令
CMD ["/bin/sh", "run.sh"]
